'''
Company: TWL
Author: xue jian
Email: xuejian@kanzhun.com
Date: 2020-11-12 09:21:31
'''
#
# @lc app=leetcode.cn id=922 lang=python3
#
# [922] 按奇偶排序数组 II
#

# @lc code=start
from typing import List
class Solution:
    def sortArrayByParityII(self, A: List[int]) -> List[int]:
        odd, even = [], []
        for i in A:
            if i%2:
                odd.append(i)
            else:
                even.append(i)
        for i in range(len(A)):
            if i%2:
                A[i]=odd[i//2]
            else:
                A[i]=even[i//2]
        return A

# @lc code=end

